<template>
	<view class="news-box">
		<view class="list-box flex" v-for="(item,index) in articleList" :key="index" @click="onDetail(item.id)">
			<view class="left-detail">
				<view class="name-txt family s28 f500">
					{{item.description}}
				</view>
				<view class="number-box s20 family f400">
					{{item.views}}人观看
				</view>
				<view class="user-info-box flex">
					<view class="user-head">
						<image class="user-image w100 h100" :src="item.shop.avatar_url" mode=""></image>
					</view>
					<view class="user-name family f400 s22">
						{{item.shop.shopname}}
					</view>
				</view>
			</view>
			<view class="right-image-box">
				<image class="news-img w100 h100" :src="'https://sz.vvv5g.com/' + item.image" mode=""></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				articleList: []
			}
		},
		onLoad() {
			this.getList()
		},
		methods: {
			getList() {
				this.$request({
					url: 'article/getList',
					method: 'POST',
					data: {
						shop_id: this.$store.state.shop.id
					}
				}).then(res => {
					this.articleList = res.data.data.data
				})
			},
			onDetail(id) {
				uni.navigateTo({
					url: '/pages/news/newsDetails?id=' + id
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.news-box {
		overflow: hidden;

		.list-box {
			width: 686upx;
			height: 196upx;
			border-bottom: 1upx solid #F4F4F4;
			padding: 0 32upx 0 32upx;
			box-sizing: border-box;
			margin: 52upx auto;

			.left-detail {
				width: 428upx;
				.name-txt {
					height: 70upx;
					line-height: 35upx;
					color: #333333;
					display: -webkit-box;
					overflow: hidden;
					white-space: normal;
					text-overflow: ellipsis;
					word-wrap: break-word;
					-webkit-line-clamp:2;
					-webkit-box-orient: vertical; 
				}

				.number-box {
					color: rgba(51, 51, 51, 0.7);
					margin-top: 30upx;
				}

				.user-info-box {
					margin-top: 20upx;
					align-items: center;

					.user-head {
						width: 32upx;
						height: 32upx;
						border-radius: 50%;
						background-color: #999;

						.user-image {
							border-radius: 50%;
						}
					}

					.user-name {
						color: #333333;
						margin-left: 12upx;
					}
				}
			}

			.right-image-box {
				width: 170upx;
				height: 170upx;
				background-color: #999;
				margin-left: 38upx;
				.news-img {
					border-radius: 8upx;
				}
			}
		}
	}
</style>
